/***************************************************************
 *
 * (c) 2008 Markus Dittrich 
 *
 * This program is free software; you can redistribute it 
 * and/or modify it under the terms of the GNU General Public 
 * License Version 3 as published by the Free Software Foundation. 
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License Version 3 for more details.
 *
 * You should have received a copy of the GNU General Public 
 * License along with this program; if not, write to the Free 
 * Software Foundation, Inc., 59 Temple Place - Suite 330, 
 * Boston, MA 02111-1307, USA.
 *
 ****************************************************************/

/* Qt includes */
#include <QColor>

/* boost includes */
#include <boost/assign/std/vector.hpp> 

/* local includes */
#include "plot_properties.h"

/* needed for += assignment operator */
using namespace boost::assign;


/****************************************************************
 *
 * definitions for class PlotProperties 
 *
 ***************************************************************/

/*****************************************************************
 *
 * public member functions
 *
 *****************************************************************/

//----------------------------------------------------------------
// constructor
//----------------------------------------------------------------
PlotProperties::PlotProperties()
  :
  hidden_(false),
  lineWidth_(1),
  circleDiameter_(4)
{
  // nothing to do here
}

//----------------------------------------------------------------
// Init functions
//----------------------------------------------------------------
void PlotProperties::Init()
{
  color_ = colorList_.get_color();
  penStyle_ = DEFAULT_PEN_STYLE;
}


//----------------------------------------------------------------
// get graph color 
//----------------------------------------------------------------
const QColor& PlotProperties::get_color() const
{
  return color_;
}


//----------------------------------------------------------------
// get draw style
//----------------------------------------------------------------
const QString& PlotProperties::get_penStyle() const
{
  return penStyle_;
}


//----------------------------------------------------------------
// get line width
//----------------------------------------------------------------
int PlotProperties::get_lineWidth() const
{
  return lineWidth_;
}


//----------------------------------------------------------------
// get diameter of circle glyph 
//----------------------------------------------------------------
int PlotProperties::get_circleDiameter() const
{
  return circleDiameter_;
}


//----------------------------------------------------------------
// get visibility state (true = visible, false = hidden)
//----------------------------------------------------------------
bool PlotProperties::is_hidden() const
{
  return hidden_;
}


//----------------------------------------------------------------
// set graph color
//----------------------------------------------------------------
void PlotProperties::set_color(QColor newColor)
{
  color_ = newColor;
}


//----------------------------------------------------------------
// set pen style
//----------------------------------------------------------------
void PlotProperties::set_penStyle(QString newPenStyle)
{
  penStyle_ = newPenStyle;
}


//----------------------------------------------------------------
// set graph visibility 
//----------------------------------------------------------------
void PlotProperties::set_visibility(bool newState)
{
  hidden_ = newState;
}


//----------------------------------------------------------------
// set line width 
//----------------------------------------------------------------
void PlotProperties::set_line_width(int newWidth)
{
  lineWidth_ = newWidth;
}


//----------------------------------------------------------------
// define static data members
//----------------------------------------------------------------
ColorList PlotProperties::colorList_;



/****************************************************************
 *
 * definitions for class ColorList
 *
 ***************************************************************/

//----------------------------------------------------------------
// constructor
//----------------------------------------------------------------
ColorList::ColorList()
  :
    currentColorIndex_(0)
{
  colorList_ += "blue","red","green","cyan","magenta","brown";
  colorList_ += "orange","purple","indigo","maroon";
}


//----------------------------------------------------------------
// return next color in sequence 
//----------------------------------------------------------------
QString ColorList::get_color() const
{
  QString color = colorList_[currentColorIndex_];

  if ( currentColorIndex_ < (colorList_.size() - 1) )
  {
    ++currentColorIndex_;
  }
  else
  {
    currentColorIndex_ = 0;
  }
  
  return color;
}
